//
//  LLDateUtilis.m
//  TaoTuo
//
//  Created by admin on 2019/10/10.
//  Copyright © 2019 admin. All rights reserved.
//

#import "LLDateUtilis.h"

@implementation LLDateUtilis

+ (NSDateComponents *)compareFromDateString:(NSString *)fromDateString toDateString:(NSString *)toDateString deteUnit:(DateUnit)dateUnit
{
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    
    NSDate *date1 = [formatter dateFromString:fromDateString];
    NSDate *date2 = [formatter dateFromString:toDateString];
    
    NSCalendar *calendar = [NSCalendar currentCalendar];
    
    NSCalendarUnit unit = (NSCalendarUnit)dateUnit;
    NSDateComponents *delt = [calendar components:unit fromDate:date1 toDate:date2 options:0];
    
    return delt;
}

///获取当前时间
+ (NSString *)getCurrentTimeString
{
    //现在的时间
    NSDate *date = [NSDate dateWithTimeIntervalSinceNow:0/*3600 * 8*/];
    NSDateFormatter *forMatter = [[NSDateFormatter alloc] init];
    [forMatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSString *dateStr = [forMatter stringFromDate:date];
    return dateStr;
}


@end
